﻿/*

#include "../../../../../../unittest/framework/unittest.hh"
#include "box/service_context.hh"
#include "box/service_box.hh"
#include "box/service_logger.hh"
#include "detail/service_logger_impl.hh"
#include "fwd.h"
#include <fstream>

FIXTURE_BEGIN(test_log)

SETUP([]() {
        {
        std::ofstream ofs;
        ofs.open("config_test_log.cfg", std::ios::trunc | std::ios::out);
        ofs << "listener = {\r"
            "   host = (\"127.0.0.1:10001\")\r"
            "}\r"

            "box_channel_recv_buffer_len = 1024\r"
            "box_name = \"test_guild\"\r"

            "service = {\r"
            "   service_dir = "
            "\"../../../../tmp\"\r"
            "}\r"

            "debugger = {\r"
            "   enable = \"true\"\r"
            "   listen = \"0.0.0.0:10888\"\r"
            "}\r"

            "service_finder = {\r"
            "   type = \"zookeeper\"\r"
            "   hosts = \"127.0.0.1:2181\"\r"
            "}\r"

            "statistics = {\r"
            "   is_open_rpc_stat = \"true\"\r"
            "}";
        ofs.close();
    }
})

CASE(TestLog1) {
    kratos::service::ServiceBox box;
    const char *argv_service[] = {"test_log",
                                  "--config=config_test_log.cfg",
                                  "--proxy-host=127.0.0.1:10002"};

    ASSERT_TRUE(box.start(3, argv_service));

    guild_service::common::singleton_start<guild_service::common::service_logger>(box.get_context());
    LOG_FAIL_S << "fail" << "ed" << LOG_END_S;
    LOG_WARN_S << LOG_END_S;
    LOG_WARN_S << "" << LOG_END_S;
    LOG_INFO_S << "info" << LOG_END_S;
    guild_service::common::singleton_stop<guild_service::common::service_logger>();
    
    ASSERT_TRUE(box.stop());
}

CASE(TestLog2) {
    kratos::service::ServiceBox box;
    const char *argv_service[] = {"test_log",
                                  "--config=config_test_log.cfg",
                                  "--proxy-host=127.0.0.1:10002"};

    ASSERT_TRUE(box.start(3, argv_service));

    ASSERT_TRUE(guild_service::common::singleton_start<guild_service::common::service_logger>(box.get_context()));
    ASSERT_TRUE(LOG_DEBUG("") >= 0);
    // ASSERT_TRUE(LOG_INFO("%s") >= 0);  //! core dump
    ASSERT_TRUE(LOG_EXCEPT("%s", "") >= 0);
    ASSERT_TRUE(LOG_WARN("%d", "hello") >= 0);
    ASSERT_TRUE(LOG_FAIL("%.2f", 3.14) >= 0);
    ASSERT_TRUE(guild_service::common::singleton_stop<guild_service::common::service_logger>());

    ASSERT_TRUE(box.stop());
}

FIXTURE_END(test_log)
*/